package com.eascs.spider.hr.user.controller;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.site.view.ViewContext;
import com.eascs.spider.hr.common.controller.BaseMasterViewController;
import com.eascs.spider.hr.user.entity.Condition;
import com.eascs.spider.hr.user.entity.Result;
import com.eascs.spider.hr.user.entity.ResultProj;
import com.eascs.spider.hr.user.service.HrService;
import com.google.gson.Gson;

@Controller
public class HrViewController extends BaseMasterViewController{

	private static Logger logger = LoggerFactory.getLogger(HrViewController.class);
	@Inject
	private HrService hrService;
	
	@RequestMapping("/hr/query")
	public String getResume(Condition condition) {
		logger.info("condition入参：{}", new Gson().toJson(condition));
		ResultProj resultProj = hrService.query(condition);
		List<Result> results = resultProj.getResults();
		ViewContext.put("totalPage", resultProj.getTotalPage());
		ViewContext.put("currentPage", resultProj.getCurrentPage());
		ViewContext.put("results", results);
		ViewContext.put("page_conditon", condition);
		ViewContext.put("resultNum", resultProj.getDocuments().size());
		logger.info("conditon回参：{}", new Gson().toJson(condition));
		return "/view/result";
	}
	
}
